﻿package ygg.encoding.swf.tag
{
	import flash.utils.ByteArray;
	import j.sus2maj7.encoding.*;
	
	import ygg.encoding.swf.*;
	
	public class TagBinary extends SwfBinary
	{
		
		public function TagBinary(ba:ByteArray=null)
		{
			super(ba);
		}
		
		public function readRGB():uint
		{
			return readUBits(24);
		}
		public function readU8():uint
		{
			return readUnsignedByte();
		}
		public function readU16():uint
		{
			return readUnsignedShort();
		}
		public function readEncU32():uint
		{
			this.syncBits();
			var result:uint  = this.readUBits(8);
			
			if (!(result & 0x80))
			{
				return result;
			}
			
			result = (result & 0x0000007f) | this.readUBits(8)<<7;
			if (!(result & 0x00004000))
			{
				
				return result;
			}
			
			result = (result & 0x00003fff) | this.readUBits(8)<<14;
			if (!(result & 0x00200000))
			{
				
				return result;
			}
			
			result = (result & 0x001fffff) | this.readUBits(8)<<21;
			if (!(result & 0x10000000))
			{
				
				return result;
			}
			
			result = (result & 0x0fffffff) | this.readUBits(8)<<28;
			
			
			return result;
		}
	}
}